package com.lyh.dt.server;

import com.lyh.dt.utils.DtActiveMqUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;


/**
 * @author liuyuhong
 */
@Component
public class ExecListenerDtMessage implements ApplicationListener<ContextRefreshedEvent> {

    private static final Logger logger = LoggerFactory.getLogger(ExecListenerDtMessage.class);

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        if (contextRefreshedEvent.getApplicationContext().getParent() == null) {
            logger.info("开始监听全局事务消息");
            DtActiveMqUtil.listenerDtMessageForTm();
        }
    }
}
